import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';




import P04 from './P04';
import P05 from './P05';
import P06 from './P06';

interface Users {
	page_size: number;
	dataArray: string[];
	menu_no: string;
	count: number;
}



export default async function a009(fd: IFeidaoAiBrowserComponent, args: Users) {

	const query = args as Users;
	query.page_size = get(fd, 'page_size');
	// console.log(query)
	const res1 = await nodejs<Users>('menu/zj-000001/s008', query);
	// console.log(res1, '00');
	if (res1.dataArray.length !== 0) {
		render(fd, res1.dataArray, P06, 'P06', 'inner');
		res1.page_size = get(fd, 'page_size');
		if (res1.count > res1.page_size) {
			render(fd, res1, P05, 'P05', 'inner');
		}
		const node = fd.data.node.querySelector<HTMLInputElement>('[data-feidao-id=' + query.menu_no + ']');
		// console.log(node)
		const nodes = node.parentNode as HTMLDivElement;
		set_node_cls(nodes, 'bg-c', true);
	} else {
		set(fd, 'flag', 0);
		render(fd, '', P04, 'P04', 'inner');
	}
}
